package cn.itlaobing.eshopmanagement.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.itlaobing.eshopmanagement.entity.Focus;
import cn.itlaobing.eshopmanagement.service.FocussService;

@Controller
@RequestMapping("/pnzFocuss")
public class FocussController extends BaseController{
	
	@Autowired
	private FocussService focussService;
	
	@RequestMapping(method=RequestMethod.GET)
	public String index(Model model) {
		Map<String, String> map=buildPageRequestSearchFilter();
		model.addAttribute("focuss", focussService.selectByPrimaryAll(map));
		return "pnzFocuss/index";
	}
	
	@RequestMapping(value="/{id}",method=RequestMethod.GET)
	public String show(@PathVariable Long id,Model model) {
		model.addAttribute("focus", focussService.selectByPrimaryKey(id));
		return "pnzFocuss/banner_detial";
	}
	
	@RequestMapping(value="/{id}",method=RequestMethod.DELETE)
	@ResponseBody
	public Map<String, String> delete(@PathVariable Long id,Model model) {
		Focus focus=focussService.selectByPrimaryKey(id);
		focussService.deleteByPrimaryKey(id);
		Map<String, String> map=new HashMap<>();
		map.put("message", "删除"+focus.getTitle()+"成功");
		map.put("id", ""+id);
		return map;
	}
}
